package controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import orm.Reply;
import orm.Users;
import services.ReplyBiz;

@Controller
public class ReplyAction {

	@Autowired
	ReplyBiz replyBiz;
	
	//查询帖子的全部回复
	@RequestMapping("getAllReply")
	public String test3(String t_id,HttpSession session){
		System.out.println("帖子id:"+t_id);
		session.setAttribute("allReply", replyBiz.getAllReply(Integer.parseInt(t_id)));
		return "readtie.jsp";
	}
	
	//发表评论
	@RequestMapping("addReply")
	public String test(int t_id,String t_content,HttpSession session){
		System.out.println("tid:"+t_id);
		Users user = (Users) session.getAttribute("user");
		System.out.println("userid:"+user.getUser_id());
		
		Reply r = new Reply();
		r.setTie_id(t_id);
		r.setUser(user);
		r.setReply_content(t_content);
		
		replyBiz.addReply(r);
		//查询单个帖子的action
		return "readTie.spring";
	}
	
}
